<script>
  import { createEventDispatcher } from "svelte";
  const dispatch = createEventDispatcher();
  export let name;
  let sendToParent = () => {
    let detail = { name: "子组件触发事件" };
    console.log("子组件触发事件");
    dispatch("childEvent", detail);
  };
</script>

<div>
  <h1>Child</h1>
  <p>{name}</p>
  <button on:click={sendToParent}>子传父</button>
</div>
